import 'dart:js' as js;
/// A constant that is true if the application was compiled to run on the web.
/// This implementation takes advantage of the fact that JavaScript does not
/// support integers. In this environment, Dart's doubles and ints are
/// backed by the same kind of object. Thus a double `0.0` is identical
/// to an integer `0`. This is not true for Dart code running in AOT or on the
/// VM.
const bool runOnH5 = identical(0, 0.0);
/**
 * js 调用桥（主要目的是因为打包app 时候 dart.js app 没法打包，到时候这里面调用的东西需要更改成app方式的）
 */
class JSBridge {
  static const String detail = 'detail';
  static const String defalt_home = 'defalt_home';
  static const String js_home = 'js_home';
  static const String erp_home = 'erp_home';
  static String getNativeProperty(String key) {
    return  callMethod("getProperty",objName:"obtain",args:[key]);
  }

  static String   callMethod( String methodName,{String objName,List args}   ) {

    if(objName!=null&&objName.isNotEmpty ){
      var context = js.context[objName];
      if (context != null) {
        return js.context[objName].callMethod(methodName,args);
      }
   return null;
    }
    return js.context.callMethod(methodName,args);
  }

  //
  static   Object getProperty({String objName,String propertyName})=> js.context[objName][propertyName];

}
